package com.yp.lession.redisqf211.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: COS
 * @time: 2022/3/25 11:31
 * @description:
 */
public class DateUtils {

    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    public static Date stringToDate(String date){
        try {
            return sdf.parse(date);
        } catch (ParseException | NullPointerException e) {
            e.printStackTrace();
            //出现异常返回null值
            return null;
        }

    }
}
